package com.hyl.auth.config.mybatis;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @Description TODO
 * @Author hyl
 * @Date 2023/6/19 17:18
 **/
@Component
public class CommonMetaObjectHandler implements MetaObjectHandler {
	/**
	 * 新增
	 * @param metaObject
	 */
	@Override
	public void insertFill(MetaObject metaObject) {
		//参数1：元数据对象
		//参数2：属性名称
		//参数3：类对象
		//参数4：当前系统时间
		this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
		this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
	}
	@Override
	public void updateFill(MetaObject metaObject) {
		this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
	}
}